// 获取哈希类型的灰度配置
function getCompanyConfigList() {
  const result = {};
  const configList =
    document.querySelector('.el-textarea__inner').value.split(',') || [];
  return configList;
}

function checkCompany() {
  const companyStr = prompt(
    '请输入需校验灰度企业字符串（以逗号、分号或空格分隔）'
  );
  let checkPass = true;

  if (!companyStr) return;
  // 去除引号，再以逗号或分号或空格分割
  const companyList =
    companyStr.replace(/["'“”‘’]+/g, '').match(/[^;；,， ]+/g) || [];
  const configList = getCompanyConfigList();
  const repetitionCompanyList = [];
  const repetitionCompanyMap = {};

  configList.forEach(config => {
    companyList.forEach(company => {
      if (config === company) {
        repetitionCompanyList.push(company);
        repetitionCompanyMap[company] = true;
      }
    });
  });
  if (repetitionCompanyList.length > 0) {
    checkPass = false;
    console.error(`企业已经存在！: `, repetitionCompanyList.join(', '));
  }
  const notRepeatCompanyList = companyList.filter(
    company => !repetitionCompanyMap[company]
  );
  console.log('未重复企业：', notRepeatCompanyList.join(','));
  checkPass && console.log('没有已存在企业！');
}

checkCompany();
